﻿using FluentValidation;

namespace TestService.WebAPI.Controllers
{
    public record Req(string name,int age);
    public class AddAdminUserRequestValidator : AbstractValidator<Req>
    {
        public AddAdminUserRequestValidator()
        {
            RuleFor(e => e.name)
                .NotNull().WithMessage("姓名不能为空")
                .NotEmpty().WithMessage("姓名不能为空")
                .MaximumLength(5).WithMessage("姓名过长");
            RuleFor(e => e.age)
                .GreaterThanOrEqualTo(20).WithMessage("年龄错误");
        }
    }
}
